package com.yufei.ui.utils;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collection;

import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JDialog;


/**
 * created by @author jasstion at 2012-9-19
 * as a button in the dialog that user can click to show a list information for the Collection
 */
public class ListButton extends JButton {
private Object source=null;
	public Object getSource() {
	return source;
}

public void setSource(Object source) {
	this.source = source;
}

	public ListButton(final Object source,String label,final JDialog parent,final Class elementType) {
		// TODO Auto-generated constructor stub
		super(label);
		this.addActionListener(new ActionListener() {
			
			
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				//to show the collection information


					JDialog jDialog=ComponentFactory.createDialogForCollectionInformation(parent, true, (Collection)source,elementType);
					jDialog.setVisible(true);
				
				
			}
		});
	}

	public ListButton(Icon icon) {
		super(icon);
		// TODO Auto-generated constructor stub
	}

	public ListButton(String text) {
		super(text);
		// TODO Auto-generated constructor stub
	}

	public ListButton(Action a) {
		super(a);
		// TODO Auto-generated constructor stub
	}

	public ListButton(String text, Icon icon) {
		super(text, icon);
		// TODO Auto-generated constructor stub
	}

}
